from core.basehandler import BaseHandler
from core.room import Room
from core.support import set_cutscene, get_game
from core.action import Action

class LookDown2(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)
        
        # self.treasure_locked = True
        # self.add_item(Keys())
        self.add_action(StepBackFromLedge)
        self.add_action(GoForIt)
    
    def get_description(self):
        game = get_game()
        player = game.get_player()
        
        if player.has_status("knows_escape_plan"):
            desc = '''
            You look down at the first floor of SMG.  
            The undergrad zombies below still groan like wombats during mating season. 
            Looks like we can make our escape with the secret plan! We'd better swing on the grappling hook.
            '''
        else:
            desc = '''
            You look down at the first floor of SMG.
            The undergrad zombies below still groan like wombats during mating season. How can I get past them??    
            '''
        return desc
    
    def get_image(self):
        return 'Lookdown2nd.jpg'

class LookDown2Handler(BaseHandler):
    def get_room_class(self):
        return LookDown2

class StepBackFromLedge(Action):
    def __init__(self):
        Action.__init__(self, "StepBackFromLedge")
    
    def get_description(self):
        return "Step back from the Ledge"
    
    def get_destination(self):
        return "secondfloorhallway"
    
    def get_method(self):
        return "get"
    
class GoForIt(Action):
    def __init__(self):
        Action.__init__(self, "GoForIt")
    
    def get_description(self):
        return "Escape!!"
    
    def get_destination(self):
        game = get_game()
        player = game.get_player()
        if player.has_status("JUICED"):
            return 'victory_room'
        else:
            return 'failure_room'
    
    def is_enabled(self):
        player = get_game().get_player()
        return player.has_status("knows_escape_plan") and player.has_status("hooked_in")and 'GrapplingGun' in player.inventory;
    def get_method(self):
        return "get"
